<title><?=$this->translate('create_ad');?></title>
<style>
    input,textarea{
        width: 90%;
    }
    #propertyType-label{
        margin-top: 3%;
    }    
    #depositeValue,#prerentValue{
        margin-top: -12%;
        margin-left: 35%;
    }
    .requiredField{
        /*color:red;*/
        box-shadow: 0px 0px 10px red;
    }
</style>
<script>
    $(function() {
        $("#addesc-label").remove();
        /**
         * vacant-date
         */
        $("#vac-date-label").remove();
        $("#vac-date-element").hide();
        $("#vac-date").datepicker({dateFormat: 'yy-mm-dd'});
        $("input[type=radio][name=vacant]").click(function() {
            if ($(this).is(':checked')) {
                if ($(this).val() == 2) {
                    $("#vac-date-element").show();
                } else {
                    $("#vac-date-element").hide();
                }
            }
        });
        if ($("input[type=radio][name=vacant]").is(':checked')) {
            if ($("#vacant-2").attr('checked') == "checked") {
                $("#vac-date-element").show();
            } else {
                $("#vac-date-element").hide();
            }
        }

        /**
         * pets-data
         */
        $("#pets-data-label").remove();
        $("#pets-data-element").hide();
        $("input[type=radio][name=pets]").click(function() {
            if ($(this).is(':checked')) {
                if ($(this).val() == 0) {
                    $("#pets-data-element").show();
                } else {
                    $("#pets-data-element").hide();
                }
            }
        });
        if ($("input[type=radio][name=pets]").is(':checked')) {
            if ($("#pets-0").attr('checked') == "checked") {
                $("#pets-data-element").show();
            } else {
                $("#pets-data-element").hide();
            }
        }


        /**
         * area append by meter square
         */
        $("#area-element").append(' m<sup>2</sup>');
//        $('#depositeSelect').append($('#depositeValue'));


        /**
         * Check for submit
         */

        $("input[name='submit']").click(function() {
            var isError = true;
            var firstThis;
            var index = 0;
            var errorMessage = "Please Enter Value...!!!";
            if ($("#adTitle").val().length == 0) {
                index++;
                firstThis = $("#adTitle");
                errorMessage = "Enter Headline Text";
                isError = false;
            } else if ($("#adDesc").val().length == 0) {
                index++;
                firstThis = $("#adDesc");
                errorMessage = "Enter Description";
                isError = false;
            }
            if (index == 0) {
                $("input[type='text']").each(function() {
                    var required = $(this).attr('req');
                    var val = $(this).val();
                    if (required === "req") {
                        if (val.length === 0) {
                            index++;
                            if (index == 1) {
                                firstThis = $(this);
                                errorMessage = $(this).attr('errMsg');
                                isError = false;
                            }
                        }
                    }
                });
            }
            if (index > 0) {
                alert(errorMessage);
                $(firstThis).focus();
            }
            return isError;
        });

    });
</script>
<div id="view-content">
    <h2><?=$this->translate('create_ad');?></h2>
    <div class="row-fluid">
        <div class="span6 well">
            <?php echo $this->form; ?>
        </div>
    </div>
</div>